import * as React from "react"
import type { Metadata } from "next"
import { unstable_noStore as noStore } from "next/cache"

import { Shell } from "@/components/shell"
import { getInformationLists } from "@/lib/information/service"
import { InformationClient } from "@/components/information/information-client"
import { InformationButton } from "@/components/information/information-button"
import { useTranslation } from "@/i18n"

export const metadata: Metadata = {
  title: "인포메이션 관리",
  description: "페이지별 도움말 및 첨부파일을 관리합니다.",
}

interface InformationPageProps {
  params: Promise<{ lng: string }>
}

export default async function InformationPage({ params }: InformationPageProps) {
  noStore()
  
  const { lng } = await params
  const { t } = await useTranslation(lng, 'menu')

  // 초기 데이터 로딩 (간단화)
  const initialData = await getInformationLists()

  // 서버사이드에서 번역된 데이터 생성
  const translatedData = initialData?.data?.map(item => ({
    ...item,
    translatedPageName: t(item.pageName)
  })) || []

  return (
    <Shell className="gap-2">
      <div className="flex items-center justify-between space-y-2">
        <div className="flex items-center justify-between space-y-2">
          <div>
            <div className="flex items-center gap-2">
              <h2 className="text-2xl font-bold tracking-tight">
                인포메이션 관리
              </h2>
              <InformationButton pagePath="/evcp/information" />
            </div>
          </div>
        </div>
      </div>
      <InformationClient initialData={translatedData} />
    </Shell>
  )
} 